home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2427 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: news.th-darmstadt.de!news!enno
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: overloading []
  5. Date: 17 Jan 1996 19:09:00 GMT
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Distribution: world
  8. Message-ID: <ENNO.96Jan17200900@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <4dgjbl$6i3@news1.goodnet.com> <4dh86s$bfi@locutus.rchland.ibm.com>
  10.     <4di9v9$8k6@news.bridge.net>
  11. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  12. In-reply-to: David Byrden's message of 17 Jan 1996 07:54:17 GMT
  13.  
  14. In article <4di9v9$8k6@news.bridge.net> David Byrden <100101.2547@compuserve.com> writes:
  15.  
  16.    >> No, you could do:
  17.  
  18.    >>     foo& f( *new foo );
  19.    >>  later on:
  20.  
  21.    >>     delete &f;
  22.  
  23.  
  24.    Phil, I believe the C++ standards committee have decided to play safe by 
  25.    declaring this kind of code as "ill-formed". In other words, a 'perfect' 
  26.    C++ compiler need not behave as you want here.
  27.  
  28. I hope not. IMO such code is reasonable. It takes advantage of the fact,
  29. that according to DWP 'new' has either to return an object or throw an
  30. exception. Using a pointer instead of the reference throws away this
  31. knowledge. Thus the program would need additional nullpointer-checks to
  32. safely dereference the pointer, which seems tedious to me.
  33. Anyway how should a compiler detect such situations in a more general
  34. context ?
  35.  
  36.         Enno
  37.  
  38.  
  39.